<?php

/**
 * This is the model class for table "cs_surrendpolicy".
 *
 * The followings are the available columns in table 'cs_surrendpolicy':
 * @property integer $id
 * @property string $CWaterNo
 * @property string $PolicyNum
 * @property string $ProductCode
 * @property string $ProdFixedId
 * @property string $StartDate
 * @property string $EndDate
 * @property double $Premium
 * @property string $CancelReason
 * @property string $StrXml
 * @property integer $create_time
 */
class Db2CsSurrender extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cs_surrendpolicy';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('CWaterNo, PolicyNum, ProductCode, ProdFixedId, StartDate, EndDate, Premium, CancelReason, create_time', 'required'),
			array('create_time', 'numerical', 'integerOnly'=>true),
			array('Premium', 'numerical'),
			array('CWaterNo, PolicyNum, ProductCode, ProdFixedId, StartDate, EndDate, StrXml', 'length', 'max'=>45),
			array('CancelReason', 'length', 'max'=>500),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, CWaterNo, PolicyNum, ProductCode, ProdFixedId, StartDate, EndDate, Premium, CancelReason, StrXml, create_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'CWaterNo' => 'Cwater No',
			'PolicyNum' => 'Policy Num',
			'ProductCode' => 'Product Code',
			'ProdFixedId' => 'Prod Fixed',
			'StartDate' => 'Start Date',
			'EndDate' => 'End Date',
			'Premium' => 'Premium',
			'CancelReason' => 'Cancel Reason',
			'StrXml' => 'Str Xml',
			'create_time' => 'Create Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('CWaterNo',$this->CWaterNo,true);
		$criteria->compare('PolicyNum',$this->PolicyNum,true);
		$criteria->compare('ProductCode',$this->ProductCode,true);
		$criteria->compare('ProdFixedId',$this->ProdFixedId,true);
		$criteria->compare('StartDate',$this->StartDate,true);
		$criteria->compare('EndDate',$this->EndDate,true);
		$criteria->compare('Premium',$this->Premium);
		$criteria->compare('CancelReason',$this->CancelReason,true);
		$criteria->compare('StrXml',$this->StrXml,true);
		$criteria->compare('create_time',$this->create_time);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * @return CDbConnection the database connection used for this class
	 */
	public function getDbConnection()
	{
		return Yii::app()->db2;
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Db2CsSurrender the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
